<?php

namespace Home\Controller;
#use Think\Cache\Driver\Redis;
use Think\Controller;

class RedisController extends Controller {
    //redis队列操作
    //入列rpush
    function listin() {
        $redis=new \Redis();
        $redis->connect('192.168.1.63',6379);
        $redis->auth('redispwd');
        echo "Connection to server successfully.";
        echo "<br>Server is run:".$redis->ping();
        echo "<br>";

        $redis->rPush("testlist1",a,b,c,d);
        echo "<br>list count:".$redis->lLen("testlist1");

        $this->display();
    }

    //出列blpop
    function listout(){
        $redis=new \Redis();
        $redis->connect('192.168.1.63',6379);
        $redis->auth('redispwd');
        echo "Connection to server successfully.";
        echo "<br>Server is run:".$redis->ping();
        echo "<br>";

        $arrlist=$redis->blPop("testlist1",999);
        echo "redis list:";
        print_r($arrlist);
        echo "<br>list count:".$redis->lLen("testlist1");
        
        $this->display();
    }


    //info信息统计
    function moinfo() {
        $redis=new \Redis();
        $redis->connect('192.168.1.63',6379);
        $redis->auth('redispwd');
//        echo "Connection to server successfully.";
//        echo "<br>Server is run:".$redis->ping();
//        echo "<br>";

         $rinfo=$redis->info();
         //dump($rinfo);
        $this->assign('rinfo',$rinfo);
        $this->display();
    }

    //重置数据
    function resetinfo() {
        $redis=new \Redis();
        $redis->connect('192.168.1.63',6379);
        $redis->auth('redispwd');

        $redis->resetStat();
        $this->redirect("Redis/moinfo",0,2,info数据已重置);
    }

    function head()
    {
        $this->display();
    }

    function graph() {
        $this->display();
    }

    function index() {
        $this->display();
    }
}